<%@page import="com.mpc.params.MainTabPageParams"%>
<%@page import="com.mpc.manager.PageManager"%>
<%@page import="com.mpc.manager.PageManager.*"%>
<%@page import="com.mpc.manager.UriManager"%>
<%@page import="com.mpc.beans.TabResources"%>
<%@page import="com.mpc.adapter.LanguagesAdapter"%>
<%@page import="com.mpc.utils.Log"%>
<%
    TabResources tabRes = (TabResources) request.getSession()
            .getAttribute(LanguagesAdapter.LANGUAGES);

    String query = request.getQueryString();
    if (query != null && query.length() > 0) {
        MainTabPageParams params = MainTabPageParams
                .parse(query, false);
        if (params != null) {
            String lan = MainTabPageParams.parse(query, false)
                    .getLanguages();
            tabRes = new TabResources(lan);
        }
    }

    PageManager pMgr = PageManager.getInstance();
    String servletContext = request.getServletContext()
            .getContextPath();
    String uriHome = pMgr.getHtmlPageUri(servletContext,
            PageManager.NAME_PAGE_HOME, tabRes.getLanguages());
    String uriApps = pMgr.getHtmlPageUri(servletContext,
            PageManager.NAME_PAGE_APPS, tabRes.getLanguages());
    String uriContact = pMgr.getHtmlPageUri(servletContext,
            PageManager.NAME_PAGE_CONACT, tabRes.getLanguages());

    HtmlUri uriCur = pMgr.getHtmlPageUriFromJspPageUri(request);

    String uriCurZh = uriCur.baseUri + "_" + LanguagesAdapter.LAN_ZH
            + UriManager.HTML_SUFFIX;
    String uriCurEn = uriCur.baseUri + "_" + LanguagesAdapter.LAN_EN
            + UriManager.HTML_SUFFIX;

    String tabActive = "class=\"active\"";
    String homeActive = "";
    String appsActive = "";
    String contactActive = "";
    int pageCode = pMgr.getPageCodeFromJspUri(request);
    if (pageCode == PageManager.INDEX_PAGE_HOME) {
        homeActive = tabActive;
    } else if (pageCode == PageManager.INDEX_PAGE_APPS) {
        appsActive = tabActive;
    } else if (pageCode == PageManager.INDEX_PAGE_CONTACT) {
        contactActive = tabActive;
    }
%>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon"
	href="<%=getServletContext().getContextPath()%>/assets/ico/favicon.ico">

<title><%=tabRes.getProjectName()%></title>

<!-- Bootstrap core CSS -->
<link
	href="<%=getServletContext().getContextPath()%>/dist/css/bootstrap.min.css"
	rel="stylesheet">

<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

<!-- Custom styles for this template -->
<link
	href="<%=getServletContext().getContextPath()%>/assets/carousel.css"
	rel="stylesheet">
</head>
<!-- NAVBAR
================================================== -->
<body>
	<div class="navbar-wrapper">
		<div class="container">

			<div class="navbar navbar-inverse navbar-static-top"
				role="navigation">
				<div class="container">
					<div class="navbar-header">
						<button type="button" class="navbar-toggle" data-toggle="collapse"
							data-target=".navbar-collapse">
							<span class="sr-only">Toggle navigation</span> <span
								class="icon-bar"></span> <span class="icon-bar"></span> <span
								class="icon-bar"></span>
						</button>
						<a class="navbar-brand" href="<%=uriHome%>"><%=tabRes.getProjectName()%></a>
					</div>
					<div class="navbar-collapse collapse">
						<ul class="nav navbar-nav">
							<li <%=homeActive%>><a href="<%=uriHome%>"><%=tabRes.getTabTitleHome()%></a></li>
							<li <%=appsActive%>><a href="<%=uriApps%>"><%=tabRes.getTabTitleApps()%></a></li>
							<li <%=contactActive%>><a href="<%=uriContact%>"><%=tabRes.getTabTitleContact()%></a></li>
							<li class="dropdown"><a href="#" class="dropdown-toggle"
								data-toggle="dropdown"><%=tabRes.getTabTitleLanguages()%> <b
									class="caret"></b></a>
								<ul class="dropdown-menu">
									<li><a href="<%=uriCurEn%>"><%=tabRes.getMenuEnglish()%></a></li>
									<li><a href="<%=uriCurZh%>"><%=tabRes.getMenuChinese()%></a></li>
								</ul></li>
						</ul>
					</div>
				</div>
			</div>

		</div>
	</div>